package com.ninjastries;

import java.util.LinkedList;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;

public class DefineEntryLayout extends Activity implements OnClickListener {
	
	//Declare global variables
	public static int textBoxId = 0;
	public static int buttonId;
	public static int[] buttonMap = {
		R.id.buttonR0,
		R.id.buttonR1
	};
	public Button buttonR0;
	public Button buttonR1;
	public EditText listName;
	public LinearLayout linearLayoutR2;
	public LinkedList<EditText> textBoxList;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.defineentrylayout);
		
		//Define global variables
		buttonR0 = (Button)findViewById(buttonMap[0]);
		buttonR1 = (Button)findViewById(buttonMap[1]);
		listName = (EditText)findViewById(R.id.editTextR0);
		linearLayoutR2 = (LinearLayout)findViewById(R.id.linearLayoutR2);
		textBoxList = new LinkedList<EditText>();
		
		//Declare local variables
		EditText firstTextBox = new EditText(this);
		
		//Use setup methods
		firstTextBox.setId(textBoxId);
		firstTextBox.setHint("Label entry slot:");
		textBoxId++;
		linearLayoutR2.addView(firstTextBox);
		textBoxList.add(firstTextBox);
		listName.setHint("Name list:");
		buttonR0.setOnClickListener(this);
		buttonR0.setText("Save");
		buttonR1.setOnClickListener(this);
		buttonR1.setText("Add Label");
	}
	
	public void onClick(View v) {
		buttonId = v.getId();
		for(int i = 0; i < buttonMap.length; i++) {
			if(buttonId == buttonMap[i]) {
				buttonId = i;
			}
		}
		
		if(buttonId == 0) {
			
		}
		
		if(buttonId == 1) {
			EditText newTextBox = new EditText(this);
			newTextBox.setId(textBoxId);
			newTextBox.setHint("Label entry slot:");
			textBoxId++;
			linearLayoutR2.addView(newTextBox);
			textBoxList.add(newTextBox);
		}
	}
}